home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Sysmon120a.lha / sysmon / src / AlertDump.c next >
C/C++ Source or Header  |  2002-01-06  |  29KB  |  803 lines

  1. /*
  2. **    $RCSfile: AlertDump.c,v $
  3. **    $Filename: AlertDump.c $
  4. **    $Revision: 1.3 $
  5. **    $Date: 2001/04/28 19:51:58 $
  6. **
  7. **    sysmon.library support command AlertDump (version 1.5)
  8. **    
  9. **    (C) Copyright 1999-2002 by Etienne Vogt
  10. */
  11.  
  12. #include <exec/alerts.h>
  13. #include <mmu/alerts.h>
  14. #include <memory/memalerts.h>
  15. #include <dos/dos.h>
  16. #include <workbench/startup.h>
  17. #define __USE_SYSBASE
  18. #include <proto/exec.h>
  19. #include <proto/dos.h>
  20. #include <exec/execbase.h>
  21. #include <string.h>
  22. #include <stdlib.h>
  23. #include "sysmon.h"
  24.  
  25. #ifndef AFF_68060
  26. #define    AFB_68060    7
  27. #define AFF_68060    (1L<<7)
  28. #endif
  29.  
  30. ULONG __saveds main(void);
  31. static void cleanexit(ULONG rc);
  32. static STRPTR alerttype(ULONG alertnum);
  33. static STRPTR alertsub(ULONG alertnum);
  34. static STRPTR alertgen(ULONG alertnum);
  35. static STRPTR alertobj(ULONG alertnum);
  36. static STRPTR alertname(ULONG alertnum);
  37. static char *cpustr(UWORD cpuflags);
  38.  
  39. static UBYTE version[] = "$VER: AlertDump 1.5 (6.1.2002)";
  40. static UBYTE template[] = "CLEAR/S";
  41.  
  42. #define    OPT_CLEAR    0
  43. #define    OPTMAX        1
  44.  
  45. struct ExecBase *SysBase;
  46. struct DosLibrary *DOSBase;
  47. static struct WBStartup *wbmsg;
  48. static struct RDArgs *myrda;
  49. struct SysmonBase *SysmonBase;
  50.  
  51. ULONG __saveds main(void)    /* No startup code */
  52. {
  53.   struct Process *myproc;
  54.   struct LastGuru *lastguru;
  55.   LONG opts[OPTMAX];
  56.  
  57.   SysBase = *(struct ExecBase **)4;
  58.   DOSBase = NULL;
  59.   SysmonBase = NULL;
  60.   wbmsg = NULL;
  61.   myrda = NULL;
  62.  
  63.   myproc = (struct Process *)FindTask(NULL);
  64.   if ((DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",36)) == NULL)
  65.   { Alert(AT_Recovery|AG_OpenLib|AO_DOSLib);
  66.     return 100;
  67.   }
  68.  
  69.   if (!(myproc->pr_CLI))        /* If started from WB, exit cleanly */
  70.   { WaitPort(&(myproc->pr_MsgPort));
  71.     wbmsg = (struct WBStartup *)GetMsg(&(myproc->pr_MsgPort));
  72.     cleanexit(20);
  73.   }
  74.  
  75.   if ((SysmonBase = (struct SysmonBase *)OpenLibrary("sysmon.library",1)) == NULL)
  76.   { PutStr("AlertDump: couldn't open sysmon.library V1+\n");
  77.     cleanexit(20);
  78.   }
  79.  
  80.   memset((char *)opts, 0, sizeof(opts));
  81.   if ((myrda = ReadArgs(template, opts, NULL)) == NULL)
  82.   { PrintFault(IoErr(),NULL);
  83.     cleanexit(20);
  84.   }
  85.  
  86.   if ((lastguru = SysmonBase->sb_LastGuru) && lastguru->lg_Sig == (ULONG)'HELP')
  87.   { UWORD cpu = SysBase->AttnFlags;
  88.  
  89.     Printf("\n%s Alert %s\n", alerttype(lastguru->lg_AlertNum), cpustr(cpu));
  90.     Printf(" Guru Meditation: %08lx  %s\n", lastguru->lg_AlertNum, alertname(lastguru->lg_AlertNum));
  91.     Printf(" Current Task   : %08lx  %.32s\n", lastguru->lg_AlertAddr, lastguru->lg_TaskName);
  92.     Printf(" SubSystem      : %s\n", alertsub(lastguru->lg_AlertNum));
  93.     Printf(" General Error  : %s\n", alertgen(lastguru->lg_AlertNum));
  94.     Printf(" Alert Object   : %s\n", alertobj(lastguru->lg_AlertNum));
  95.  
  96.     PutStr("\nInteger registers\n");
  97.     Printf(" D0-D7 = %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",lastguru->lg_DataRegs[0],lastguru->lg_DataRegs[1],lastguru->lg_DataRegs[2],lastguru->lg_DataRegs[3],lastguru->lg_DataRegs[4],lastguru->lg_DataRegs[5],lastguru->lg_DataRegs[6],lastguru->lg_DataRegs[7]);
  98.     Printf(" A0-A7 = %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",lastguru->lg_AddrRegs[0],lastguru->lg_AddrRegs[1],lastguru->lg_AddrRegs[2],lastguru->lg_AddrRegs[3],lastguru->lg_AddrRegs[4],lastguru->lg_AddrRegs[5],lastguru->lg_AddrRegs[6],lastguru->lg_AddrRegs[7]);
  99.     Printf(" PC = %08lx, SR = %04lx\n",lastguru->lg_PC,(LONG)lastguru->lg_SR);
  100.  
  101.     if (SysmonBase->sb_Flags & SBFF_FPU)
  102.     { PutStr("\nFloating Point registers\n");
  103.       Printf(" FP0-FP1 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[0],lastguru->lg_FloatRegs[1],lastguru->lg_FloatRegs[2],lastguru->lg_FloatRegs[3],lastguru->lg_FloatRegs[4],lastguru->lg_FloatRegs[5]);
  104.       Printf(" FP2-FP3 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[6],lastguru->lg_FloatRegs[7],lastguru->lg_FloatRegs[8],lastguru->lg_FloatRegs[9],lastguru->lg_FloatRegs[10],lastguru->lg_FloatRegs[11]);
  105.       Printf(" FP4-FP5 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[12],lastguru->lg_FloatRegs[13],lastguru->lg_FloatRegs[14],lastguru->lg_FloatRegs[15],lastguru->lg_FloatRegs[16],lastguru->lg_FloatRegs[17]);
  106.       Printf(" FP6-FP7 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[18],lastguru->lg_FloatRegs[19],lastguru->lg_FloatRegs[20],lastguru->lg_FloatRegs[21],lastguru->lg_FloatRegs[22],lastguru->lg_FloatRegs[23]);
  107.       Printf(" FPCR = %08lx, FPSR = %08lx, FPIAR = %08lx\n",lastguru->lg_FPCR,lastguru->lg_FPSR,lastguru->lg_FPIAR);
  108.     }
  109.  
  110.     PutStr("\nSystem registers\n");
  111.     Printf(" USP = %08lx, ",lastguru->lg_USP);
  112.     if ((cpu & AFF_68020) && (cpu & AFF_68060) == 0)
  113.     { Printf("ISP = %08lx, MSP = %08lx\n",lastguru->lg_SSP,lastguru->lg_MSP);
  114.     }
  115.     else
  116.     { Printf("SSP = %08lx\n",lastguru->lg_SSP);
  117.     }
  118.     if (cpu & AFF_68010)
  119.     { Printf(" VBR = %08lx, SFC = %08lx, DFC = %08lx\n",lastguru->lg_VBR,lastguru->lg_SFC,lastguru->lg_DFC);
  120.       if (cpu & AFF_68020)
  121.       { Printf(" CACR = %08lx",lastguru->lg_CACR);
  122.     if ((cpu & AFF_68040) == 0) Printf(", CAAR = %08lx",lastguru->lg_CAAR);
  123.     PutStr("\n");
  124.     if (cpu & AFF_68030)
  125.     { if (cpu & AFF_68040)
  126.       { Printf(" ITT0 = %08lx, ITT1 = %08lx, DTT0 = %08lx, DTT1 = %08lx\n",lastguru->lg_ITT0,lastguru->lg_ITT1,lastguru->lg_DTT0,lastguru->lg_DTT1);
  127.         Printf(" TC = %08lx, URP = %08lx, SRP = %08lx\n",lastguru->lg_TC,lastguru->lg_URP,lastguru->lg_SRP);
  128.       }
  129.       else
  130.       { Printf(" TT0 = %08lx, TT1 = %08lx\n",lastguru->lg_ITT0,lastguru->lg_ITT1);
  131.         Printf(" TC = %08lx, CRP = %08lx%08lx, SRP = %08lx%08lx\n",lastguru->lg_TC,lastguru->lg_DTT0,lastguru->lg_DTT1,lastguru->lg_URP,lastguru->lg_SRP);
  132.       }
  133.       if (cpu & AFF_68060) Printf(" PCR = %08lx, BUSCR = %08lx\n",lastguru->lg_MSP,lastguru->lg_MMUSR);
  134.       else if (cpu & AFF_68040) Printf(" MMUSR = %08lx\n",lastguru->lg_MMUSR);
  135.       else Printf(" MMUSR = %04lx\n",lastguru->lg_MMUSR >> 16);
  136.     }
  137.       }
  138.     }
  139.  
  140.     if (opts[OPT_CLEAR]) lastguru->lg_Sig = 0;
  141.   }
  142.   else PutStr("No LastGuru data available\n");
  143.  
  144.   cleanexit(0);
  145. }
  146.  
  147. static void cleanexit(ULONG rc)
  148. {
  149.   if (myrda) FreeArgs(myrda);
  150.   if (DOSBase) CloseLibrary((struct Library *)DOSBase);
  151.   if (SysmonBase) CloseLibrary((struct Library *)SysmonBase);
  152.   if (wbmsg)
  153.   { Forbid();
  154.     ReplyMsg((struct Message *)wbmsg);
  155.   }
  156.   Exit(rc);
  157. }
  158.  
  159. static STRPTR alerttype(ULONG alertnum)
  160. { if (alertnum & AT_DeadEnd) return "DeadEnd";
  161.   else return "Recoverable";
  162. }
  163.  
  164. static STRPTR alertsub(ULONG alertnum)
  165. { switch (alertnum & 0x7f000000)
  166.   { case AN_ExecLib:
  167.       return "exec.library";
  168.     case AN_GraphicsLib:
  169.       return "graphics.library";
  170.     case AN_LayersLib:
  171.       return "layers.library";
  172.     case AN_Intuition:
  173.       return "intuition.library";
  174.     case AN_MathLib:
  175.       return "math*.library";
  176.     case 0x06000000:
  177.       return "clist.library (obsolete)";
  178.     case AN_DOSLib:
  179.       return "dos.library";
  180.     case AN_RAMLib:
  181.       return "ramlib";
  182.     case AN_IconLib:
  183.       return "icon.library";
  184.     case AN_ExpansionLib:
  185.       return "expansion.library";
  186.     case AN_DiskfontLib:
  187.       return "diskfont.library";
  188.     case AN_AudioDev:
  189.       return "audio.device";
  190.     case AN_ConsoleDev:
  191.       return "console.device";
  192.     case AN_GamePortDev:
  193.       return "gameport.device";
  194.     case AN_KeyboardDev:
  195.       return "keyboard.device";
  196.     case AN_TrackDiskDev:
  197.       return "trackdisk.device";
  198.     case AN_TimerDev:
  199.       return "timer.device";
  200.     case AN_CIARsrc:
  201.       return "cia.resource";
  202.     case AN_DiskRsrc:
  203.       return "disk.resource";
  204.     case AN_MiscRsrc:
  205.       return "misc.resource";
  206.     case AN_BootStrap:
  207.       return "strap";
  208.     case AN_Workbench:
  209.       return "Workbench";
  210.     case AN_DiskCopy:
  211.       return "DiskCopy";
  212.     case AN_GadTools:
  213.       return "gadtools.library";
  214.     case AN_UtilityLib:
  215.       return "utility.library";
  216.     case AN_Unknown:
  217.       return "Unknown";
  218.     case AN_MEMLib:            /* THOR subsystem codes */
  219.       return "memory.library";
  220.     case AN_MMULib:
  221.       return "mmu.library";
  222.     case 0x3f000000:
  223.       return "680x0.library";
  224.     case 0x40000000:
  225.       return "sysmon.library";        /* my subsystem codes */
  226.     case 0x50000000:
  227.       return "vdisk.device";
  228.     case 0x70000000:
  229.       return "ErrorLogD";
  230.     default:
  231.       return "N/A";
  232.   }
  233. }
  234.  
  235. static STRPTR alertobj(ULONG alertnum)
  236. { switch (alertnum & 0x0000ffff)
  237.   { case AO_ExecLib:
  238.       return "exec.library";
  239.     case AO_GraphicsLib:
  240.       return "graphics.library";
  241.     case AO_LayersLib:
  242.       return "layers.library";
  243.     case AO_Intuition:
  244.       return "intuition.library";
  245.     case AO_MathLib:
  246.       return "math*.library";
  247.     case 0x00008006:
  248.       return "clist.library (obsolete)";
  249.     case AO_DOSLib:
  250.       return "dos.library";
  251.     case AO_RAMLib:
  252.       return "ramlib";
  253.     case AO_IconLib:
  254.       return "icon.library";
  255.     case AO_ExpansionLib:
  256.       return "expansion.library";
  257.     case AO_DiskfontLib:
  258.       return "diskfont.library";
  259.     case AO_AudioDev:
  260.       return "audio.device";
  261.     case AO_ConsoleDev:
  262.       return "console.device";
  263.     case AO_GamePortDev:
  264.       return "gameport.device";
  265.     case AO_KeyboardDev:
  266.       return "keyboard.device";
  267.     case AO_TrackDiskDev:
  268.       return "trackdisk.device";
  269.     case AO_TimerDev:
  270.       return "timer.device";
  271.     case AO_CIARsrc:
  272.       return "cia.resource";
  273.     case AO_DiskRsrc:
  274.       return "disk.resource";
  275.     case AO_MiscRsrc:
  276.       return "misc.resource";
  277.     case AO_BootStrap:
  278.       return "strap";
  279.     case AO_Workbench:
  280.       return "Workbench";
  281.     case AO_DiskCopy:
  282.       return "DiskCopy";
  283.     case AO_GadTools:
  284.       return "gadtools.library";
  285.     case AO_UtilityLib:
  286.       return "utility.library";
  287.     case AO_Unknown:
  288.       return "Unknown";
  289.     case 0x0000803d:
  290.       return "memory.library";
  291.     case 0x0000803e:
  292.       return "mmu.library";
  293.     case 0x0000803f:
  294.       return "680x0.library";
  295.     case 0x00008040:
  296.       return "sysmon.library";
  297.     case 0x00008050:
  298.       return "vdisk.device";
  299.     case 0x00008070:
  300.       return "ErrorLogD";
  301.     default:
  302.       return "N/A";
  303.   }
  304. }
  305.  
  306. static STRPTR alertgen(ULONG alertnum)
  307. { switch (alertnum & 0x00ff0000)
  308.   { case AG_NoMemory:
  309.       return "Not enough memory";
  310.     case AG_MakeLib:
  311.       return "Library initialization failure";
  312.     case AG_OpenLib:
  313.       return "OpenLibrary() failure";
  314.     case AG_OpenDev:
  315.       return "OpenDevice() failure";
  316.     case AG_OpenRes:
  317.       return "OpenResource() failure";
  318.     case AG_IOError:
  319.       return "I/O error";
  320.     case AG_NoSignal:
  321.       return "No signal available";
  322.     case AG_BadParm:
  323.       return "Bad parameter(s) to function";
  324.     case AG_CloseLib:
  325.       return "Mismatched or too many CloseLibrary()";
  326.     case AG_CloseDev:
  327.       return "Mismatched or too many CloseDevice()";
  328.     case AG_ProcCreate:
  329.       return "Process creation failed";
  330.     default:
  331.       return "N/A";
  332.   }
  333. }
  334.  
  335. static STRPTR alertname(ULONG alertnum)
  336. { ULONG num = alertnum & 0x7fffffff;
  337.  
  338.   if ((num >= 0x00000010 && num < 0x00000018) || num == 0x0000003B || num == 0x0000003E || num == 0x0000003F)
  339.     return "ACPU_Reserved (Reserved CPU vector)";
  340.   if (num >= 0x00000040 && num < 0x000000FF) return "ACPU_User (Quick interrupt vector)";
  341.  
  342.   switch (num)
  343.   { case 0x00000001:        /* CPU Exception alerts */
  344.       return "ACPU_Reset (System reset or shutdown)";
  345.     case 0x00000002:
  346.       return "ACPU_BusErr (Bus or access error)";
  347.     case 0x00000003:
  348.       return "ACPU_AddressErr (Odd address error)";
  349.     case 0x00000004:
  350.       return "ACPU_InstErr (Illegal instruction)";
  351.     case 0x00000005:
  352.       return "ACPU_DivZero (Division by zero)";
  353.     case 0x00000006:
  354.       return "ACPU_CHK (CHK instruction exception)";
  355.     case 0x00000007:
  356.       return "ACPU_TRAPV (TRAPcc instruction exception)";
  357.     case 0x00000008:
  358.       return "ACPU_PrivErr (Privilege violation)";
  359.     case 0x00000009:
  360.       return "ACPU_Trace (Trace exception)";
  361.     case 0x0000000A:
  362.       return "ACPU_LineA (Unimplemented line 1010 instruction)";
  363.     case 0x0000000B:
  364.       return "ACPU_LineF (Unimplemented line 1111 instruction)";
  365.     case 0x0000000C:
  366.       return "ACPU_EmulInt (Emulation mode interrupt)";
  367.     case 0x0000000D:
  368.       return "ACPU_CoproErr (Coprocessor protocol violation)";
  369.     case 0x0000000E:
  370.       return "ACPU_Format (Stack frame format error)";
  371.     case 0x0000000F:
  372.       return "ACPU_UnInitInt (Uninitialized interrupt)";
  373.     case 0x00000018:
  374.       return "ACPU_Spurious (Spurious interrupt error)";
  375.     case 0x00000019:
  376.       return "ACPU_AutoVec1 (AutoVector Level 1 interrupt)";
  377.     case 0x0000001A:
  378.       return "ACPU_AutoVec2 (AutoVector Level 2 interrupt)";
  379.     case 0x0000001B:
  380.       return "ACPU_AutoVec3 (AutoVector Level 3 interrupt)";
  381.     case 0x0000001C:
  382.       return "ACPU_AutoVec4 (AutoVector Level 4 interrupt)";
  383.     case 0x0000001D:
  384.       return "ACPU_AutoVec5 (AutoVector Level 5 interrupt)";
  385.     case 0x0000001E:
  386.       return "ACPU_AutoVec6 (AutoVector Level 6 interrupt)";
  387.     case 0x0000001F:
  388.       return "ACPU_AutoVec7 (AutoVector Level 7 interrupt)";
  389.     case 0x00000020:
  390.       return "ACPU_Trap0 (TRAP #0 exception)";
  391.     case 0x00000021:
  392.       return "ACPU_Trap1 (TRAP #1 exception)";
  393.     case 0x00000022:
  394.       return "ACPU_Trap2 (TRAP #2 exception)";
  395.     case 0x00000023:
  396.       return "ACPU_Trap3 (TRAP #3 exception)";
  397.     case 0x00000024:
  398.       return "ACPU_Trap4 (TRAP #4 exception)";
  399.     case 0x00000025:
  400.       return "ACPU_Trap5 (TRAP #5 exception)";
  401.     case 0x00000026:
  402.       return "ACPU_Trap6 (TRAP #6 exception)";
  403.     case 0x00000027:
  404.       return "ACPU_Trap7 (TRAP #7 exception)";
  405.     case 0x00000028:
  406.       return "ACPU_Trap8 (TRAP #8 exception)";
  407.     case 0x00000029:
  408.       return "ACPU_Trap9 (TRAP #9 exception)";
  409.     case 0x0000002A:
  410.       return "ACPU_TrapA (TRAP #A exception)";
  411.     case 0x0000002B:
  412.       return "ACPU_TrapB (TRAP #B exception)";
  413.     case 0x0000002C:
  414.       return "ACPU_TrapC (TRAP #C exception)";
  415.     case 0x0000002D:
  416.       return "ACPU_TrapD (TRAP #D exception)";
  417.     case 0x0000002E:
  418.       return "ACPU_TrapE (TRAP #E exception)";
  419.     case 0x0000002F:
  420.       return "ACPU_TrapF (TRAP #F exception)";
  421.     case 0x00000030:        /* FPU exceptions */
  422.       return "AFPU_BSUnord (Branch or Set on unordered condition)";
  423.     case 0x00000031:
  424.       return "AFPU_Inexact (Inexact result)";
  425.     case 0x00000032:
  426.       return "AFPU_FDivZero (Floating-point division by zero)";
  427.     case 0x00000033:
  428.       return "AFPU_Underflow (Floating-point underflow)";
  429.     case 0x00000034:
  430.       return "AFPU_Operand (Operand error)";
  431.     case 0x00000035:
  432.       return "AFPU_Overflow (Floating-point overflow)";
  433.     case 0x00000036:
  434.       return "AFPU_SNaN (Signaling Not a Number)";
  435.     case 0x00000037:
  436.       return "AFPU_UnDType (Unimplemented FP data type)";
  437.     case 0x00000038:        /* MMU exceptions */
  438.       return "AMMU_Config (Configuration error)";
  439.     case 0x00000039:
  440.       return "AMMU_IllOp (Illegal operation)";
  441.     case 0x0000003A:
  442.       return "AMMU_AccessErr (Access level violation)";
  443.     case 0x0000003C:
  444.       return "ACPU_UnEffAddr (Unimplemented effective address)";
  445.     case 0x0000003D:
  446.       return "ACPU_UnIntInst (Unimplemented integer instruction)";
  447.     
  448.     case 0x01000001:        /* exec.library alerts */
  449.       return "AN_ExcptVect (Bad CPU exception vectors checksum)";
  450.     case 0x01000002:
  451.       return "AN_BaseChkSum (Bad ExecBase checksum)";
  452.     case 0x01000003:
  453.       return "AN_LibChkSum (Bad library jumptable checksum)";
  454.     case 0x01000004:
  455.       return "AN_LibMem (No memory for ExecBase structure)";
  456.     case 0x01000005:
  457.       return "AN_MemCorrupt (Corrupted memory list)";
  458.     case 0x01000006:
  459.       return "AN_IntrMem (No memory for interrupt servers)";
  460.     case 0x01000007:
  461.       return "AN_InitAPtr (InitStruct() with a 24bit address)";
  462.     case 0x01000008:
  463.       return "AN_SemCorrupt (Illegal semaphore state)";
  464.     case 0x01000009:
  465.       return "AN_FreeTwice (Freeing memory already freed)";
  466.     case 0x0100000A:
  467.       if (alertnum & AT_DeadEnd) return "AN_BogusExcpt (Illegal CPU exception taken)";
  468.       else return "AN_UnInitExcpt (Uninitialized task exception)";
  469.     case 0x0100000B:
  470.       return "AN_IOUsedTwice (Pending IORequest reused)";
  471.     case 0x0100000C:
  472.       return "AN_MemoryInsane (Sanity check on memory list failed)";
  473.     case 0x0100000D:
  474.       return "AN_IOAfterClose (Closed IORequest reused)";
  475.     case 0x0100000E:
  476.       return "AN_StackProbe (Stack out of range)";
  477.     case 0x0100000F:
  478.       return "AN_BadFreeAddr (Memory header not located)";
  479.     case 0x01000010:
  480.       return "AN_BadSemaphore (Obsolete semaphore structure used)";
  481.     case 0x010000FF:
  482.       return "AN_UnQuickIntr (Uninitialized quick interrupt)";
  483.     case 0x01000011:        /* PoolMem alerts */
  484.       return "AN_MemHeadInsane (MemHeader Insane)";
  485.     case 0x01000012:
  486.       return "AN_InvDelHeader (Invalid DeleteHeader, internal)";
  487.     case 0x01000013:
  488.       return "AN_IllScratch (Scratch Entry Illegal)";
  489.     case 0x01000014:
  490.       return "AN_UnordPools (Memory Pools Unordered)";
  491.     case 0x01000015:
  492.       return "AN_AllocUnder (AllocMem Underflow)";
  493.     case 0x01000016:
  494.       return "AN_FreeOver (FreeMem Overflow)";
  495.  
  496.     case 0x02010000:        /* graphics.library alerts */
  497.       return "AN_GfxNoMem (No memory for graphics.library)";
  498.     case 0x02010001:
  499.       return "AN_GfxNoMemMspc (No memory for MonitorSpec)";
  500.     case 0x02010002:
  501.       return "AN_CopInstr (No memory for Copperlist)";
  502.     case 0x02000003:
  503.       return "AN_CopListOver (Copperlist overload)";
  504.     case 0x02000004:
  505.       return "AN_CopIListOver (Intermediate Copperlist overload)";
  506.     case 0x02010005:
  507.       return "AN_CopListHead (No memory for Copperlist head)";
  508.     case 0x02010006:
  509.       return "AN_LongFrame (No memory for long-frame Copperlist)";
  510.     case 0x02010007:
  511.       return "AN_ShortFrame (No memory for short-frame Copperlist)";
  512.     case 0x02010008:
  513.       return "AN_FloodFill (No memory for Flood Fill)";
  514.     case 0x02010009:
  515.       return "AN_TextTmpRas (No memory for Text TmpRas)";
  516.     case 0x0201000A:
  517.       return "AN_BltBitMap (No memory for BltBitMap)";
  518.     case 0x0201000B:
  519.       return "AN_RegionMemory (No memory for Region)";
  520.     case 0x0200000C:
  521.       return "AN_GfxNewError (Illegal node type for GfxNew)";
  522.     case 0x0200000D:
  523.       return "AN_GfxFreeError (Bad ExtendedNode for GfxFree)";
  524.     case 0x02000030:
  525.       return "AN_MakeVPort (No memory for MakeVPort)";
  526.     case 0x02000401:
  527.       return "AN_ObsoleteFont (Obsolete font description)";
  528.     case 0x02011234:
  529.       return "AN_GfxNoLCM (Emergency memory not available)";
  530.  
  531.     case 0x03010000:        /* layers.library alerts */
  532.       return "AN_LayersNoMem (No memory for layers.library)";
  533.  
  534.     case 0x04000001:        /* intuition.library alerts */
  535.       return "AN_GadgetType (Unknown gadget type)";
  536.     case 0x04010002:
  537.       return "AN_CreatePort (No memory for CreatePort)";
  538.     case 0x04010003:
  539.       return "AN_ItemAlloc (No memory for MenuItem plane)";
  540.     case 0x04010004:
  541.       return "AN_SubAlloc (No memory for SubItem plane)";
  542.     case 0x04010005:
  543.       return "AN_PlaneAlloc (No memory for plane)";
  544.     case 0x04000006:
  545.       return "AN_ItemBoxTop (Item box in negative region)";
  546.     case 0x04010007:
  547.       return "AN_OpenScreen (No memory for OpenScreen)";
  548.     case 0x04010008:
  549.       return "AN_OpenScrnRast (No memory for raster in OpenScreen)";
  550.     case 0x04000009:
  551.       return "AN_SysScrnType (Unknown sys screen type)";
  552.     case 0x0401000A:
  553.       return "AN_AddSWGadget (No memory to add gadget)";
  554.     case 0x0401000B:
  555.       return "AN_OpenWindow (No memory for OpenWindow)";
  556.     case 0x0400000C:
  557.       return "AN_BadState (Bad State entering Intuition)";
  558.     case 0x0400000D:
  559.       return "AN_BadMessage (Bad Message received by IDCMP)";
  560.     case 0x0400000E:
  561.       return "AN_WeirdEcho (Weird echo on deferred action)";
  562.     case 0x0400000F:
  563.       return "AN_NoConsole (Couldn't open console.device)";
  564.     case 0x04000010:
  565.       return "AN_NoISem (Intuition skipped obtaining a sem)";
  566.     case 0x04000011:
  567.       return "AN_ISemOrder (Intuition obtained a sem in bad order)";
  568.  
  569.     case 0x07000000:        /* dos.library alerts */
  570.       return "AN_Startup (Error initializing DOS)";
  571.     case 0x07010001:
  572.       return "AN_StartMem (No memory at DOS startup)";
  573.     case 0x07000002:
  574.       return "AN_EndTask (Task could not be terminated)";
  575.     case 0x07000003:
  576.       return "AN_QPktFail (Invalid link from DosPacket to Message)";
  577.     case 0x07000004:
  578.       return "AN_AsyncPkt (Unexpected packet received)";
  579.     case 0x07000005:
  580.       return "AN_FreeVec (Incorrect length in FreeVec)";
  581.     case 0x07000006:
  582.       return "AN_DiskBlkSeq (Disk block sequence error)";
  583.     case 0x07000007:
  584.       return "AN_BitMap (Defective bitmap)";
  585.     case 0x07000008:
  586.       return "AN_KeyFree (Block already free)";
  587.     case 0x07000009:
  588.       return "AN_BadChkSum (Invalid block checksum)";
  589.     case 0x0700000A:
  590.       return "AN_DiskError (Disk error)";
  591.     case 0x0700000B:
  592.       return "AN_KeyRange (Block number outside valid range)";
  593.     case 0x0700000C:
  594.       return "AN_BadOverlay (Error in overlay supervisor)";
  595.     case 0x0700000D:
  596.       return "AN_BadInitFunc (Invalid shell initialization packet)";
  597.     case 0x0700000E:
  598.       return "AN_FileReclosed (FileHandle closed more than once)";
  599.  
  600.     case 0x08000001:        /* ramlib alerts */
  601.       return "AN_BadSegList (Overlay in shared library)";
  602.  
  603.     case 0x0A000001:        /* expansion.library alerts */
  604.       return "AN_BadExpansionFree (Expansion slot already free)";
  605.  
  606.     case 0x11000001:        /* console.device alerts */
  607.       return "AN_NoWindow (Can't open initial window)";
  608.  
  609.     case 0x14000001:        /* trackdisk.device alerts */
  610.       return "AN_TDCalibSeek (Seek error during calibration)";
  611.     case 0x14000002:
  612.       return "AN_TDDelay (Timer error while waiting)";
  613.  
  614.     case 0x15000001:        /* timer.device alerts */
  615.       return "AN_TMBadReq (Invalid timerequest)";
  616.     case 0x15000002:
  617.       return "AN_TMBadSupply (No ticks from power supply)";
  618.  
  619.     case 0x21000001:        /* disk.resource alerts */
  620.       return "AN_DRHasDisk (Unit already active)";
  621.     case 0x21000002:
  622.       return "AN_DRIntNoAct (Interrupt without an active unit)";
  623.  
  624.     case 0x30000001:        /* strap alerts */
  625.       return "AN_BootError (Boot code returned an error)";
  626.  
  627.     case 0x31000001:        /* Workbench alerts */
  628.       if (alertnum & AT_DeadEnd) return "AN_NoFonts (Unable to open default font)";
  629.       else return "AN_WBBadStartupMsg1 (Bad StartupMsg returned)";
  630.     case 0x31000002:
  631.       return "AN_WBBadStartupMsg2 (Bad StartupMsg returned)";
  632.     case 0x31000003:
  633.       return "AN_WBBadIOMsg (Unrecognized internal message)";
  634.     case 0x31010004:
  635.       return "AN_WBInitPotionAllocDrawer";
  636.     case 0x31010005:
  637.       return "AN_WBCreateWBMenusCreateMenus1";
  638.     case 0x31010006:
  639.       return "AN_WBCreateWBMenusCreateMenus2";
  640.     case 0x31010007:
  641.       return "AN_WBLayoutWBMenusLayoutMenus";
  642.     case 0x31010008:
  643.       return "AN_WBAddToolMenuItem";
  644.     case 0x31010009:
  645.       return "AN_WBReLayoutToolMenu";
  646.     case 0x3101000A:
  647.       return "AN_WBInitTimer";
  648.     case 0x3101000B:
  649.       return "AN_WBInitLayerDemon";
  650.     case 0x3101000C:
  651.       return "AN_WBInitWBGels";
  652.     case 0x3101000D:
  653.       return "AN_WBInitScreenAndWindows1";
  654.     case 0x3101000E:
  655.       return "AN_WBInitScreenAndWindows2";
  656.     case 0x3101000F:
  657.       return "AN_WBInitScreenAndWindows3";
  658.     case 0x31010010:
  659.       return "AN_WBMAlloc";
  660.  
  661.     case 0x3d000001:    /* memory.library alerts (THOR) */
  662.       return "AN_MEMPageSetup (Page modification failed)";
  663.     case 0x3d000002:
  664.       return "AN_MEMQpkt (Swap daemon packet failure)";
  665.     case 0x3d000003:
  666.       return "AN_MEMCtxtInv (Invalid context found)";
  667.     case 0x3d000004:
  668.       return "AN_MEMCmdInv (Invalid swap daemon command)";
  669.     case 0x3d000005:
  670.       return "AN_MEMInvFree (Invalid freemem)";
  671.     case 0x3d000006:
  672.       return "AN_MEMFreeFail (Releasing memory pool failed)";
  673.     case 0x3d000007:
  674.       return "AN_MEMDupKey (Duplicate key found)";
  675.  
  676.     case 0x3e090001:    /* mmu.library alerts */
  677.       return "AN_ContextOpen (Context still in use at Expunge())";
  678.     case 0x3e018005:
  679.       return "AN_BadFreePool (Internal memory pool is damaged)";
  680.     case 0x3e018001:
  681.       return "AN_NoPoolMem (No memory to build internal pool)";
  682.     case 0x3e018002:
  683.       return "AN_NoContext (No memory to build the context)";
  684.     case 0x3e000002:
  685.       return "AN_MMUInit (MMU Init vector failed)";
  686.     case 0x3e000003:
  687.       return "AN_IllegalTT (Illegal Transparent Translation mode)";
  688.     case 0x3e000004:
  689.       return "AN_IllegalMMU (Illegal MMU table layout)";
  690.     case 0x3e000005:
  691.       return "AN_BadContext (Context contains unaligned mappings)";
  692.     case 0x3e000006:
  693.       return "AN_BadTable (MMU table has been damaged)";
  694.     case 0x3e000007:
  695.       return "AN_FreeActive (Attempt to release an active context)";
  696.     case 0x3e000008:
  697.       return "AN_MapHole (Mapping contains undefined areas)";
  698.     case 0x3e000009:
  699.       return "AN_Phase (Unexpected context change required)";
  700.     case 0x3e00000a:
  701.       return "AN_BuildError (Lower tree level built failed)";
  702.     case 0x3e00000b:
  703.       return "AN_ConfigBroken (MMU config parameters invalid)";
  704.     case 0x3e00000c:
  705.       return "AN_NoRoot (No valid root pointer for context)";
  706.     case 0x3e00000d:
  707.       return "AN_NoCatcher (No catcher port for exceptions)";
  708.     case 0x3e00000e:
  709.       return "AN_ExcptBusy (Attempt to release a busy exception)";
  710.     case 0x3e00000f:
  711.       return "AN_NotCaller (Bad message hook release attempt)";
  712.     case 0x3e000073:
  713.       return "AN_QueueDaemon (Invalid reply from exception daemon)";
  714.     case 0x3e000010:
  715.       return "AN_LineWB (Unhandled line writeback fault)";
  716.     case 0x3e000011:
  717.       return "AN_LineRB (Unhandled line fetch fault)";
  718.     case 0x3e000012:
  719.       return "AN_GhostMovem (Invalid movem fault detected)";
  720.     case 0x3e000013:
  721.       return "AN_CheckMMU (CheckMMU couldn't repair test page)";
  722.     case 0x3e000014:
  723.       return "AN_BadDMA (Bad DMA transfer initiated)";
  724.     case 0x3e000015:
  725.       return "AN_PostSetup (Memory layout changed after setup)";
  726.     case 0x3e000016:
  727.       return "AN_NoMapMem (Free non-RemapSize() aligned memory)";
  728.     case 0x3e000017:
  729.       return "AN_NoMemMemList (AddMemList() MMU rebuild failed)";
  730.     case 0x3e000018:
  731.       return "AN_NoMemAddConf (AddConfigDev() MMU rebuild failed)";
  732.     case 0x3e090009:
  733.       return "AN_FreeCtxTwice (Child context detached twice)";
  734.     case 0x3e001005:
  735.       return "AN_BadShare (Can't share with non-shared context)";
  736.     case 0x3e12800a:
  737.       return "AN_NoResExp (No expansion library module)";
  738.  
  739.     case 0x3f000001:        /* THOR 680x0.libraries alerts */
  740.       return "AN_ResVector (Reserved library vector called)";
  741.     case 0x3f000002:
  742.       if (alertnum & AT_DeadEnd) return "AN_FPSPFmtErr (Invalid FPU stack format)";
  743.       else return "AN_Zombie (ColdReboot() didn't reboot)";
  744.     case 0x3f000015:
  745.       return "AN_PostSetup (Configuration changed after setup)";
  746.  
  747.     case 0x40000001:        /* sysmon.library alerts */
  748.       return "AN_smNoTaskInfo (No TaskInfo structure found)";
  749.     case 0x40010002:
  750.       return "AN_smNoTIMem (No memory for TaskInfo at startup)";
  751.     case 0x40010003:
  752.       return "AN_smSysLogBuf (No memory for syslog buffers)";
  753.     case 0x40000004:
  754.       return "AN_BadSysLogMsg (Bad SysLogMsg received by server)";
  755.     case 0x40010005:
  756.       return "AN_smNoLastGuru (No memory for LastGuru buffer)";
  757.     case 0x40010006:
  758.       return "AN_smNoAlertMem (No memory for alert.hook module)";
  759.     case 0x40000007:
  760.       return "AN_smSuperTaskSwitch (TaskSwitch in Supervisor mode)";
  761.     case 0x40000008:
  762.       return "AN_smInconSchedState (Inconsistant Scheduling State)";
  763.  
  764.     case 0x50010001:        /* vdisk.device alerts */
  765.       return "AN_VDRootMem (No memory for root structure)";
  766.     case 0x50010002:
  767.       return "AN_VDUnitMem (No memory for unit structure)";
  768.     case 0x50010003:
  769.       return "AN_VDReAlloc (Memory reallocation failed)";
  770.     case 0x50010004:
  771.       return "AN_VDAllocAbs (AllocAbs failed in AllocReverse)";
  772.     case 0x50000005:
  773.       return "AN_VDBadStartup (Error in Unit Startup)";
  774.     case 0x50010006:
  775.       return "AN_VDBadRootLoc (Root Structure in bad memory)";
  776.  
  777.     case 0x70000001:        /* ErrorLogD alerts */
  778.       return "AN_elBadMessage (Unexpected message at HellGate)";
  779.     case 0x700B0002:
  780.       return "AN_elLoggerFail (Couldn't start logger process)";
  781.     case 0x70000003:
  782.       return "AN_elNoHellGate (Couldn't find HellGate semaphore)";
  783.     case 0x70000004:
  784.       return "AN_elBadEvilLst (Evil List is corrupted)";
  785.     case 0x70000005:
  786.       return "AN_elNoDoomNode (Couldn't find DoomNode)";
  787.  
  788.     default:
  789.       if (num & 0x00008000) return "(Generic alert)";
  790.       else return "(Unknown alert code)";
  791.   }
  792. }
  793.  
  794. static char *cpustr(UWORD cpuflags)
  795. {
  796.   if (cpuflags & AFF_68060) return "68060";
  797.   else if (cpuflags & AFF_68040) return "68040";
  798.   else if (cpuflags & AFF_68030) return "68030";
  799.   else if (cpuflags & AFF_68020) return "68020";
  800.   else if (cpuflags & AFF_68010) return "68010";
  801.   else return "68000";
  802. }
  803.